package com.fulihui.wgj.service.region;

import com.alibaba.dubbo.config.annotation.Service;
import com.fulihui.common.builder.rpc.RpcResultBuilder;
import com.fulihui.common.error.InvokeServiceException;
import com.fulihui.common.result.rpc.SimpleResult;
import com.fulihui.common.util.ConditionValidator;
import com.fulihui.wgj.biz.WxRegionBiz;
import com.fulihui.wgj.facade.dto.WxRegionDTO;
import com.fulihui.wgj.facade.request.region.WxRegionQueryProvinceRequest;
import com.fulihui.wgj.facade.service.region.WxRegionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @author wang_wx
 * @date 2018-06-28
 */
@Component
@Service(interfaceClass = WxRegionService.class, version = "1.0.0", timeout = 5000)
public class WxRegionServiceImpl implements WxRegionService {

    private static final Logger LOGGER = LoggerFactory.getLogger(WxRegionServiceImpl.class);

    @Autowired
    WxRegionBiz wxRegionBiz;

    @Override
    public Map<String, String> getAllRegionMap() {
        return wxRegionBiz.getAllRegionMap();
    }

    @Override
    public SimpleResult<List<WxRegionDTO>> queryAllCountry() {
        List<WxRegionDTO> wxRegionDTOS = wxRegionBiz.queryAllCountry();
        return RpcResultBuilder.succSimple(wxRegionDTOS);
    }

    @Override
    public SimpleResult<List<WxRegionDTO>> queryProvince(WxRegionQueryProvinceRequest request) throws InvokeServiceException {
        ConditionValidator.validate(request);
        return RpcResultBuilder.succSimple(wxRegionBiz.queryProvince(request));
    }


}
